<?php
namespace app\index\model;
use think\Model;

class Avatar extends Model
{
    public function addpic($data=[]){
        try {
            if (empty($data)) {
                $this->error = "不能为空";
                return false;
            }
            $this->allowField(true)->replace(true)->save($data);
            return $this->getLastInsID();
        } catch (\Exception $e) {
            $this->error = $e->getMessage();
            return false;
        }
    }

    public function edit_pic($data=[]){
        try{
            if(empty($data)){
                $this->error="不能为空";
                return false;
            }
            if($data['pic_url']){ return $this->isUpdate(false)->allowField(true)->replace(true)->save($data);}

        }catch(\Exception $e){
            $this->error=$e->getMessage();
            return false;
        }


    }

}
